<?php
    
    function do_header($title)
    {
    ?>
        <html ng-app="myApp">
        <head>
            <title><?php echo $title;?></title>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <script src="js/jquery-2.1.3.js" type="text/javascript"></script>
            <script src="js/angular-1.2.13.js" type="text/javascript"></script>            
            <script src="js/angular-route-1.2.13.js"></script>
            <script src="js/common.js" type="text/javascript"></script>
            <link rel="stylesheet" type="text/css" href="css/foundation.css">
        </head>
        <body>
        <!-- sth else -->
    <?php 
        if(isset($title))
        {
            do_heading($title);
        }
    }
    
    function do_heading($heading)
    {
    ?>
        <h2><?php echo $heading; ?></h2>
    <?php 
    }
    
    function do_footer()
    {
    ?>        
        </body>        
        </html>
    <?php 
    }

    function diplay_registration_form()
    {
        echo file_get_contents('register.html');
    }
    
    function display_login_form()
    {
        echo file_get_contents('login.html');
    }
    
    
    function do_url($url, $text)
    {
        ?>
            <a href = "<?php echo $url;?>"><?php echo $text;?></a>
        <?php 
    }
    
    function do_url_login()
    {
        do_url("login.php", "Log in");
    }

    /**
     * 根据当前用户id输出身份信息。
     * @param unknown $id 当为null时，表示未登录
     */
    function do_userid($id)
    {
        if($id!==false)
        {
            echo "Logged in as ".$id.". ";
            do_url("logout.php", "Log out");
        }
        else
        {
            echo "You are not logged in.";
            do_url("login.php", "Log in");
        }
    }
    

    
    
    
    
    


?>